#!/usr/bin/python
#-*- coding:utf-8-*-
import json
from config import uiPath 
showImgStyle=("pt_pointer","showImg") 
showImg = {"type":"img","id":"showImg","style":showImgStyle}
userShow = {"type":"div","id":"userShow","sub":[showImg]}
userStatus ={"type":"div","id":"userStatus","attribute":{"title":"当前状态"},\
             "style":["pt_left"],"sub":[{"type":"div","style":["pt_dropdown"]}]}
userLog = {"type":"div","id":"userLog","text":"这里是微型博客更新处，限制在140个字符以内",\
            "style":["pt_left"],"attribute":{"title":"点击这里修改"}}
siteLink = {"type":"div","id":"siteLink","text":"这里PageTalk链接","style":["pt_right"]}
panelUp = {"type":"div","id":"panelUp","sub":[userStatus,userLog,siteLink]}
contact = {"type":"pt_button","id":"contactBtn","text":"联系人","style":["pt_btn"]}
msgBox = {"type":"pt_button","id":"msgBox_Btn","text":"<img src=/images/msg.png />消息","style":["pt_btn"]}
addMark = {"type":"pt_button","id":"addMark","text":"添加书签","style":["pt_btn"]}
addTab = {"type":"pt_button","id":"addTab","text":"新建标签","style":["pt_btn"]}
userLink = {"type":"div","id":"userLink","sub":[contact,msgBox,addMark,addTab]}
addressBarInput = {"type":"input","id":"addressBarInput","attribute":{"type":"test","size":50}}
openPage = {"type":"pt_button","id":"openPage","text":"打开","style":["pt_btn"]}
refreshPage = {"type":"pt_button","id":"refreshPage","text":"刷新","style":["pt_btn"]}
addressBar= {"type":"div","id":"addressBar","sub":[addressBarInput,openPage,refreshPage]}
searchBarInput = {"type":"input","id":"searchBarInput","attribute":{"type":"text","size":20}}
searchBarBtn = {"type":"pt_button","id":"searchBarBtn","text":"搜索","style":["pt_btn"]}
searchBar = {"type":"div","id":"searchBar","sub":[searchBarInput,searchBarBtn]}
panelUnder = {"type":"div","id":"panelUnder","sub":[userLink,addressBar,searchBar]}
userPanel = {"type":"div","id":"userPanel","sub":(userShow,panelUp,panelUnder)}
center = {"type":"div","style":["pt_left","pt_center"],"sub":[{"type":"div","id":"tabBox"},\
          {"type":"div","id":"activeDiv"}]}
statusBar = {"type":"div","id":"statusBar"}
UI=[userPanel,center,statusBar]
ico = "/images/check.gif"
info = {"label":"个人信息设置","ico":'/images/setting.png'}
habit = {"label":"使用习惯","ico":'/images/carers.jpg'}
myproduct = {"label":"我的产品",'ico':'/images/product.gif'}
fellow = {"label":"好友","ico":'/images/friend.gif'}
group = {"label":"群组","ico":'/images/group.gif'}
tool = {"label":"工具","ico":'/images/tool.png'}
msg = {"info":info,"habit":habit,"myproduct":myproduct,"fellow":fellow,"group":group,"tool":tool}
pres = {"rss":{"label":"阅读器","ico":ico},"bookmark":{"label":"书签","ico":ico},\
        "blog":{"label":"微博","ico":ico},"game":{"label":"游戏","ico":ico}}
sys = {"bug":{"label":"反馈Bug","ico":ico},"support":{"label":"支持","ico":ico},\
        "privacy":{"label":"隐私策略","ico":ico},"about":{"label":"关于PageTalk","ico":ico},\
        "terms":{"label":"使用条款","ico":ico},"clear":{"label":"清除本地记录","ico":ico}}
MainMenu = (msg,pres,pres,sys)
UserData = {"user":"test","home":"http://www.baidu.com","show":"/images/h.png"}
fellow = {'user_test_id':{"label":"测试个人用户","ico":'/images/list_msg.png'}}
groups = {'group_test':{"label":"测试群组","ico":'/images/list_msg.png'}}
domain = {'g.cn':{"label":"http：//g.cn","ico":'/images/list_msg.png'}}
cFellow = {'test_friend_id':{"label":"测试好友"}}
cGroup = {'test_group_id':{"label":"测试组"}}
jsContact = json.dumps((cFellow,cGroup))
MsgBox = (fellow,groups,domain)
jsUI = json.dumps(UI)
jsMainMenu = json.dumps(MainMenu)
jsUserData = json.dumps(UserData)
jsMsgBox = json.dumps(MsgBox)
html = "var UData = %s;\nvar TPNode = %s;\nvar mainMenu = %s;\nvar msgBox = %s;\nvar contactList = %s;\n" % (jsUserData,jsUI,jsMainMenu,jsMsgBox,jsContact)

f = open("%sdata.js" % (uiPath),"w")
f.write(html)
